<?php
/**
 * 登记分数
 */
session_start();
include "../util/DBUtil.php";
$login_type = $_SESSION['login_type'];//登录类型
$login_user = unserialize($_SESSION['login_user']);//反解序列获登录用户信息

$db = new DBUtil();

?>


<link rel="stylesheet" href="../css/bootstrap.min.css">
<table class="table table-striped">
    <tr>
        <th>ID</th>
        <th>学号</th>
        <th>姓名</th>
        <?php
        $sql = "select * from tb_course";
        $course_result = $db->query($sql);//课程结果集
        foreach ($course_result as $item) {
            ?>
            <th><?php echo $item['course'] ?></th>
            <?php
        }
        ?>
        <th>编辑</th>
    </tr>
    <!--添加成绩表单以格显示-->
    <?php
    $sql = "select * from tb_student where grade_id=?";
    $params = array($login_user['grade_id']);
    $student_result = $db->query($sql,$params);
    foreach ($student_result as $value) {
        ?>
        <form action="../action/score_formOK.php?action=add" method="post">
            <input type="hidden" value="<?php echo $value['id']?>" name="stuId">
            <tr>
                <td><?php echo $value['id'] ?></td>
                <td><?php echo $value['student_no'] ?></td>
                <td><?php echo $value['name'] ?></td>
                <?php
                foreach ($course_result as $item){
                ?>
                <td><input type="number" name="score<?php echo $item['id']?>" maxlength="3" minlength="1" ></td>
            <?php
            }
            ?>
                <td>
                    <a href="javascript:0" target="info">
                        <button class="btn btn-primary" type="submit">添加</button>
                    </a>
                </td>
            </tr>
        </form>
        <?
    }
    ?>

</table>
